<template>
  <div class="form-container">
    <el-row type="flex" justify="center">
      <el-form style="width:90%;" ref="form" :model="form" :inline="true" label-position="top">
        <el-row>
          <el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
            <el-form-item :label="$t('permission.name')" style="width: 80%;">
                <el-input v-model="form.tel" style="width: 100%;"/>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="10" :lg="10" :xl="10">
            <el-form-item :label="$t('user.createdAt')" style="width: 80%;">
                <el-col :span="11">
                    <el-date-picker type="date" :placeholder="$t('production.selectStartDate')" v-model="form.updateDateStart" style="width: 100%;"></el-date-picker>
                </el-col>
                <el-col class="line" :span="2">-</el-col>
                <el-col :span="11">
                    <el-date-picker type="date" :placeholder="$t('production.selectEndDate')" v-model="form.updateDateEnd" style="width: 100%;"></el-date-picker>
                </el-col>
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :md="6" :lg="6" :xl="6" class="button-container">
            <el-form-item>
              <el-button type="primary" @click="onSubmit">{{ $t('production.search') }}</el-button>
              <el-button @click="onCancel">{{ $t('production.clear') }}</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'PermissionSearchForm',
  data() {
    return {
      form: {
        name: '',
        updateDateStart: '',
        updateDateEnd: ''
      }
    }
  },
  methods: {
    onSubmit() {
      // this.$message('submit!')
      let { name, updateDateStart, updateDateEnd } = this.form
      this.$emit('update:search', {
        name,
        updateDateStart,
        updateDateEnd,
      })
    },
    onCancel() {
      this.$message({
        message: 'cancel!',
        type: 'warning'
      })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
@import "@/styles/variables.scss";
.line{
  text-align: center;
}
.button-container {
  position: relative;
}
@media screen and (min-width: $md){
    .button-container {
      position: absolute;
      right: 0;
      bottom: 1px;
    }
}
</style>

